836 - Largest submatrix (DP, programación dinámica, O(n^4) ¿Existirá un O(n^3)?)
[and.git] / 10033 - Interpreter / E.c
blob6fb97c574b17c386bcab296a682fc465a34a03f3
1 #include <stdio.h>
3 int ram[1000];
4 int r[10];
5 int i,ip,a,b,c;
7 main(){
8 while (1 == scanf("%d",&ram[i++])){}
9 for (i=1;;i++){
10 a = ram[ip]/100;
11 b = ram[ip]/10%10;
12 c = ram[ip]%10;
13 ip++;
14 if (a == 1) break;
15 if (a == 2) r[b] = c;
16 else if (a == 3) r[b] = (r[b]+c)%1000;
17 else if (a == 4) r[b] = (r[b]*c)%1000;
18 else if (a == 5) r[b] = r[c];
19 else if (a == 6) r[b] = (r[b]+r[c])%1000;
20 else if (a == 7) r[b] = (r[b]*r[c])%1000;
21 else if (a == 8) r[b] = ram[r[c]];
22 else if (a == 9) ram[r[c]] = r[b];
23 else if (a == 0 && r[c] !=0) ip = r[b];
25 printf("%d\n",i);